package 华为;

import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;

/*
* 1、芯片资源限制
* */
public class Main1 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int M=cin.nextInt(),N=cin.nextInt();
        int[] AB=new int[M+1];
        Arrays.fill(AB,4);
        int idA=1,idB=1;
        cin.nextLine();
        String[] yws = cin.nextLine().split(" ");
        for (int i = 0; i < yws.length; i++) {
            String cur=yws[i];
            if(Objects.equals(cur, ""))continue;
            if (cur.equals("A")){
                int xpid=-1;
                for (int j = 1; j < M+1; j++) {
                    if (AB[j]>0){
                        AB[j]-=1;
                        xpid=j;
                        idA=4-AB[j];
                        break;
                    }
                }
                if (xpid==-1){
                    System.out.println(0);
                    System.out.println(0);
                    return;
                }
                if (i== yws.length-1){
                    System.out.println(xpid);
                    System.out.println(idA);
                    return;
                }
            }else if (cur.equals("B")){
                int xpid=-1;
                for (int j = 1; j < M+1; j++) {
                    if (AB[j]==4){
                        AB[j]-=4;
                        xpid=j;
                        idB=1;
                        break;
                    }
                }
                if (xpid==-1){
                    System.out.println(0);
                    System.out.println(0);
                    return;
                }
                if (i== yws.length-1){
                    System.out.println(xpid);
                    System.out.println(idB);
                    return;
                }
            }
        }
    }
}
